﻿cmake_minimum_required(VERSION 3.16)

project(PyQt LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

set(Python_ROOT_DIR C:/Users/maden/.conda/envs/opencv_test)
find_package (Python COMPONENTS Interpreter Development)
message(STATUS "python find result: ${Python_INCLUDE_DIRS} ${Python_LIBRARIES}")


add_executable(PyQt
  main.cpp
)
target_link_libraries(PyQt Qt${QT_VERSION_MAJOR}::Core Python::Python)

include(GNUInstallDirs)
install(TARGETS PyQt
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

message(STATUS "Python_RUNTIME_LIBRARY_DIRS: ${Python_RUNTIME_LIBRARY_DIRS}")
file(GLOB PYTHON_DLLS "${Python_RUNTIME_LIBRARY_DIRS}/python*.dll")
add_custom_command(TARGET PyQt
                     POST_BUILD
                     COMMAND ${CMAKE_COMMAND} -E copy_if_different
                     ${PYTHON_DLLS}
                     $<TARGET_FILE_DIR:PyQt>)



